#pragma once

#include "clkHeader.h"
#include "clkMath.h"

#include "clkBody.h"
#include "clkShape.h"

class clkObject : public clkBody, public clkShape
{
public:
	//attributes
	int m_objIdx;
	int m_objBlk;
	bool m_isAsleep;
	bool m_isCollidable;
	bool m_isStationary;

	//ctor & dtor
	clkObject() : clkBody(), clkShape()
	{
		m_objIdx = -1;
		m_isAsleep = false;
		m_isCollidable = false;
		m_isStationary = false;
	}

	//create function
	void create()
	{
		switch(m_type)
		{
		case SHAPE_CIRC:
			m_width  = m_radius;
			m_height = m_radius;
			break;
		case SHAPE_RECT:
			m_radius = V2DF(m_width,m_height).magnitude();
			break;
		}

		float hw = m_width/2.0f;
		float hh = m_height/2.0f;

		m_vertA[0].set(-hw,-hh);
		m_vertA[1].set( hw,-hh);
		m_vertA[2].set( hw, hh);
		m_vertA[3].set(-hw, hh);

		m_vertAN[0].set( 0.0f,-1.0f);
		m_vertAN[1].set( 1.0f, 0.0f);
		m_vertAN[2].set( 0.0f, 1.0f);
		m_vertAN[3].set(-1.0f, 0.0f);

		m_look.set(1.0f,0.0f);
		m_right.set(0.0f,-1.0f);

		update();
	}

	//update functions
	void update()
	{
		for(int i = 0; i < 4; i++)
		{
			m_vertR[i]  = m_vertA[i];
			m_vertRN[i] = m_vertAN[i];
			rotateVec(m_vertR[i],m_rot);
			rotateVec(m_vertRN[i],m_rot);
			m_vertR[i] += m_pos;
		}

		m_look = m_vertRN[1];
		m_right = m_vertRN[2];

		m_aabb = genAABB(m_vertR);
	}
};